<%@ page language="java"  pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/views/common/taglib.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>配送员详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="HandheldFriendly" content="true" />
    <meta name="viewport" content="width=320.1, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <%@ include file="/WEB-INF/views/common/resource.jsp" %>
</head>
<body>
<div class="pop_bg"></div>
<div class="pop_box list" id="del_confirm_box" style="padding-bottom: 70px;">
    <p style="text-align: center; font-size: 19px; color: #373737;">配送员一旦删除，则无法分配订单给这位配送员</p>
    <ul class="bottom_btn">
        <li id="close">我再想想</li>
        <li onclick="deleteCourier()">确定删除</li>
    </ul>
</div>

<div class="page pt0">
    <div class="shopper_detil_head">
        <c:choose>
            <c:when test="${empty courier.courier_head_img_url}">
                <img src="${itx}/images/shopper_head.png" width="100px" />
            </c:when>
            <c:otherwise>
                <img src="${courier.courier_head_img_url}" width="100px" />
            </c:otherwise>
        </c:choose>

        <h1>${courier.courier_name}</h1>
    </div>
    <ul class="shopper_detil_infolist">
        <li>
            <span>电话：${courier.courier_mobile}</span>
            <a href="tel:${courier.courier_mobile}">呼叫</a>
        </li>
        <li id="star">
            <span>评价：</span>
        </li>
        <li>
            <span>已送达：${courier.order_num}单</span>
        </li>
    </ul>
    <div class="bottom_btns">
        <ul>
            <li style="background: #ccc; color: #333;" onclick="location.href='${ctx}/mep/toCourierEdit.do?courier_id=${courier.courier_id}'">修改</li>
            <li id="delete">删除</li>
        </ul>
    </div>
</div>
<script type="text/javascript">
    $('.pop_bg').click(function(e){
        $('.pop_bg').hide();
        $('.pop_box').hide();
    });

    $('#close').click(function(e){
        $('.pop_bg').hide();
        $('.pop_box').hide();
    });

    $('#delete').click(function(e){
        $('.pop_bg').height($(document).height());
        $('.pop_bg').show();
        $('#del_confirm_box').show();
    });

    var star = parseInt('${courier.all_score}');

    var num = parseInt('${courier.evaluate_num}');

    var i = Math.ceil(star/num);


    function showStar() {
        var html = "";
        for(var j=1;j<6;j++){
            if(j<=i){
                html = html+"<img src=\"${itx}/images/star_on.png\" width=\"22\" />";
            }else{
                html = html+"<img src=\"${itx}/images/star.png\" width=\"22\" />";
            }
        }
        $('#star').append(html);
    }

    $(document).ready(function(){
        showStar()
    });

    function deleteCourier() {
        var courier_id = '${courier_id}';
        $.ajax({
            type: "post",
            url: '/mep/deleteCourier.do',
            dataType: "json",
            data: {
                'courier_id':courier_id
            },
            success: function(resp){
                console.log(resp);
                if(resp.result==="success"){
//                    alertTips("删除成功！");
                    location.href=ctx+'/mep/toMepCouriers.do';
                }else{
                    console.log("get_order_message_error!");
                }
            }
        });

    }

</script>
</body>
</html>
